package com.sq.universe.flowable.service;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.sq.universe.base.entity.RespEntity;
import com.sq.universe.flowable.entity.WorkflowEntity;
import com.sq.universe.system.entity.UserEntity;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.engine.form.TaskFormData;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;

import java.util.List;
import java.util.Map;

public interface WorkflowService {

    /**
     * 查询待办任务
     * @param userEntity
     * @return
     */
    public PageInfo queryTodo(UserEntity userEntity, WorkflowEntity workflowEntity);

    /**
     * 根据流程实例Id获取任务
     * @param processInstanceId
     * @return
     */
    public String queryTaskId(String processInstanceId);

    /**
     * 查询全部的任务列表
     * @param userEntity
     * @return
     */
    public PageInfo taskList(UserEntity userEntity,WorkflowEntity workflowEntity);

    /**
     * 查询已完成的任务列表
     * @param userEntity
     * @return
     */
    public PageInfo queryDone(UserEntity userEntity, WorkflowEntity workflowEntity);

    /**
     * 启动任务
     * @param workflowEntity
     * @param userEntity
     */
    public void start(WorkflowEntity workflowEntity,UserEntity userEntity);

    /**
     * 完成任务
     */
    public void completeTask(WorkflowEntity workflowEntity,UserEntity userEntity);

    /**
     * 退回
     */
    public void rollback(WorkflowEntity workflowEntity, UserEntity userEntity );

    /**
     * 获取表单信息
     * @param formKey
     * @return
     */
    public TaskFormData getForm(String formKey);

    /**
     * 根据流程实例ID查询历史记录
     * @param workflowEntity
     * @return
     */
    public List history(WorkflowEntity workflowEntity);

    /**
     * 查詢任務信息
     * @param processInstanceId
     * @return
     */
    public Map<String,String> queryTaskInfo(String processInstanceId);

    /**
     * 查询当前任务，所在流程中所有的任务节点ID
     * @param taskId
     * @return
     */
    public List<Map> queryFlowNodes(String taskId);

    /**
     * 指定节点跳转
     * @param jumpData
     * @param userEntity
     */
    public void jump(JSONObject jumpData, UserEntity userEntity  );


    /**
     * 查询所有人的待办
     * @param workflowEntity
     * @return
     */
    public PageInfo queryAllTodo(WorkflowEntity workflowEntity);

    /**
     * 任务转办
     * @param data
     * @param userEntity
     * @return
     */
    public RespEntity transferTask(JSONObject data, UserEntity userEntity);

    /**
     * 激活流程
     * @param data
     * @param userEntity
     * @return
     */
    public RespEntity active(JSONObject data, UserEntity userEntity);

    /**
     * 挂起流程
     * @param data
     * @param userEntity
     * @return
     */
    public RespEntity suspend(JSONObject data, UserEntity userEntity);


    /**
     * 查询流程模型列表
     * @return
     */
    public List queryModelList(JSONObject data);

    /**
     * 数据统计
     * @param userEntity
     * @return
     */
    public Map<String,Object> taskCount(UserEntity userEntity);

    /**
     * 统计各个流程的数据
     * @return
     */
    public List<Map> groupFlowByKey();
}
